package emulator.support;

import emulator.hardware.HwByte;
import emulator.hardware.HwWord;
import emulator.util.MemoryPtr;

public class IndirectXOperandEval implements OperandEval {

	MemoryPtr instruction;
	
	public IndirectXOperandEval(MemoryPtr ptr) {
		instruction = ptr;
	}

	@Override
	public String getDetails(CpuState cpu_state) {
		int address = instruction.getByteOp();
		int reg_x = cpu_state.getValue("X");
		int zp_adr = (address+reg_x) & 0xff;
		instruction.setAddress(zp_adr);
		int ptr = instruction.getWordOp();
		instruction.setAddress(ptr);
		int value = instruction.getByteOp();
		return "(($"+new HwByte(address)+" + $"+new HwByte(reg_x) + " -> $"+new HwByte(zp_adr)+") -> $"+new HwWord(ptr)+") -> $"+new HwByte(value);
	}

}
